<%--
  Created by IntelliJ IDEA.
  User: Carson
  Date: 2022/3/23
  Time: 22:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8"
	import="java.util.*,java.sql.*" language="java"%>
<%@ page import="fhr.SQL"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>员工登录入口</title>
<!--     <link rel="icon" href="image/icon.ico" > -->
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<!--     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> -->
<!--     <meta http-equiv="description" content="This is my page"> -->
<!--     <link rel="stylesheet" href="css/style.css"> -->
</head>
<body>
	<div class="login-wrap">
		<h2>登录</h2>
		<div class="form">
			<form action="" method="post">
				<!--             <img src="image/name.png" style="width: 20px;height: 20px; " > -->
				<input type="text" placeholder="用户名" name="username" /><br>
				<!--             <img src="image/password.png" style="width: 20px;height: 20px;" > -->
				<input type="password" placeholder="密码" name="password" />
				<%
				SQL d = new SQL();
				
				d.getConnection(); // TODO
				
				String username = "";
				String password = "";
				username = request.getParameter("username");
				password = request.getParameter("password");
				String sql = "select Username from user where UserName= ? ";
				String sql1 = "select UserPwd from user where UserPwd= '" + password + "'";
				PreparedStatement preparedStatement = d.conn.prepareStatement(sql);
				preparedStatement.setString(1, username);
				
				Statement stmt1 = d.getStatement();
				Statement stmt2 = d.getStatement();
				
				ResultSet rs = stmt1.executeQuery(sql);
				ResultSet rs1 = stmt2.executeQuery(sql1);
				
				if (rs.next() && rs1.next()) {
					request.getRequestDispatcher("/user.jsp").forward(request, response);
				}
				%>
				<input type="submit" id="btnn" value="登录"
					style="margin-left: 34%; height: 40px; width: 100px;"> <a
					href="register.jsp">
					<p>没有账号？点击注册</p>
				</a>

			</form>
		</div>
	</div>

</body>
</html>
